package com.ruoyi.hr.service.impl.salaryquery;


import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.hr.mapper.salaryquery.InterfaceSalaryHsitoryMapper;
import com.ruoyi.hr.service.salaryquery.InterfaceSalaryHsitoryService;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class InterfaceSalaryHsitoryServiceImpl implements InterfaceSalaryHsitoryService {

    @Autowired
    InterfaceSalaryHsitoryMapper interfaceSalaryHsitoryMapper;

    @Autowired
    SysUserMapper sysUserMapper;

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<String> findAddPro(String jsid) {
        SysUser user = ShiroUtils.getSysUser();
        Map<String, Object> maps = sysUserMapper.selectSkySecUser(user.getLoginName());
        List<String> list = interfaceSalaryHsitoryMapper.findAddPro(jsid, maps.get("id").toString());
        return list;
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<Map<String, Object>> addList(Map map) {
        SysUser user = ShiroUtils.getSysUser();
        Map<String, Object> maps = sysUserMapper.selectSkySecUser(user.getLoginName());
        map.put("urid", maps.get("id").toString());
        map.put("pro", interfaceSalaryHsitoryMapper.findAddPro(map.get("jsid").toString(), maps.get("id").toString()));
        return interfaceSalaryHsitoryMapper.addList(map);
    }


    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<String> findAttPro() {
        return interfaceSalaryHsitoryMapper.findAttPro();
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<Map<String, Object>> attList(Map map) {
        map.put("pro", interfaceSalaryHsitoryMapper.findAttPro());
        return interfaceSalaryHsitoryMapper.attList(map);
    }
}
